home *** CD-ROM | disk | FTP | other *** search
- /* VCtest.rexx ===================================================
-
- This is a script which can be called from CLI, or from another
- program or arexx script.
-
- Purpose: To make Virus_CheckerII test a single file, or files
- ------- from a list.
-
- Usage: (a) From CLI (shell)
- ----- ---------------------
- rx VCtest <file path+name> OR rx VCtest -L<list path+name>
-
- -L may be upper or lower case.
- If a list is provided, this is a text file and it must carry
- one file path+name on each line.
- (If a path is not supplied, the current shell path is used.)
-
- (b) From DirOPus (Vn5 Magellan)
- -------------------------------
- (Button configuration)
-
- Function: AmigaDos rx <path>VCtest.rexx> {f}
- or: Arexx <path>VCtest.rexx> {f}
-
- Flags: CD source
- Do all files
- No file quotes
- Output to window
- Recursive dirs
- Window close button
- Run asynchronously (optional)
-
- Results: VCtest will normally print to window one or more file
- ------- names, each followed by one or more lines which show
- 1. Number of viruses found.
- 2. Name of infected file (if virus found)
- 3. Name of virus found (if any)
-
- Lines 2 and 3 will be repeated if any further viruses found
-
- Output may be redirected to a text file.
-
- e.g. rx VCtest >hd0:tests/mytest -lBBS:uploads/testlist
-
- Notes: Lha archives will be unpacked disregarding directories.
- ----- This means that all files in the arcgive will be put into
- the one work area (see config lines below). VC will not
- need to unpack the files, and there is no danger of files
- carrying a path (such as C:) which could cause them to
- be put into places where they can do harm.
-
- The several unpackers referred to in the script should be
- within your system's search paths, perhaps in C: or
- Utilities. These are
- Lha, Lzx, Pkax, Unarj, zoo, Unzip, DMS.
-
- If there are any which you don't intend to support,
- then delete or disable lines in the script which refer
- to these.
-
-
- Author:
- -------------------------------------------------------------------
- John Marchant ('Gnome'). Bedford UK. gnome@enterprise.net
- Amiga 4000/40, A3000/30, A500 Fidonet 2:257/137.16
- Moonlight (Amiga) BBS. 6pm-8am (24hrs weekends) +44 (0)1234 212752
- Fax, Fido freq, Fido netmail accepted during open hours.
- -------------------------------------------------------------------
- (Above information correct at 28 October 1998)
-
- =====================================================================*/
-
- options results
- options failat 21
-
- signal on failure
- signal on syntax
-
- /* The following lines can be enabled, and will provide a
- recorded 'trace' of the program.
- */
-
- /*
- call open('STDERR','ram:tracefile','w')
- trace results
- */
-
- /*=============== User configs ===================*/
-
- WorkDir = 'T:Test' /* Where you want archives to be unpacked for testing */
- VCdir = 'Work1:utilities.1/Virus_Checker/'
- /* Path to your virus checker, with trailing / */
-
- /*============ End of configs ================================*/
-
- parse arg fpath junk
-
- flist=''; infile=''; listinp=0
-
- if left(fpath,2)='-l' | left(fpath,2)='-L' then do
- flist=substr(fpath,3) /* input file = list of paths+names */
- listinp=1
- end
-
- Home_Dir=Pragma('D') /* determine current dir */
- call Pragma('S',64000) /* set stack size */
-
- if exists(WorkDir) then
- address command 'Delete >nil: 'workdir'/#? quiet' /* clear work area */
- else address command 'makedir 'WorkDir /* else make work area */
-
- call Load_VC
- if response>0 then do
- say 'Can''t find '||VCdir||Virus_CheckerII
- returncode=20
- signal badexit
- end
-
- if listinp then do
- if open(chklist,flist,'r') =0 then do
- say 'Cannot open '||flist
- say
- returncode=21
- signal badexit
- end
-
- do while ~eof(chklist)
- fpath=readln(chklist)
- if fpath='' then leave
- if ~exists(fpath) then do
- say 'Can''t find '||fpath
- iterate
- end
- say 'Testing: '||fpath
- call Unpack
- if response=0 then call Viruscheck
- say
- end
- call close(chklist)
- end
-
- else do
- if ~exists(fpath) then do
- temp_path=Home_Dir||'/'||fpath
- if exists(temp_path) then fpath=temp_path
- else do
- say 'Can''t find '||fpath
- returncode=21
- signal badexit
- end
- end
- say 'Testing: '||fpath
- call Unpack
- if response=0 then call Viruscheck
- say
- end
-
- address command 'Delete >nil: 'workdir'/#? quiet'
- gnome=Pragma('D',Home_Dir) /* return to original dir */
- exit
-
- badexit:
- gnome=Pragma('D',Home_Dir)
- return returncode
-
- /*--------------------------------------------------*/
-
- Unpack:
- /* Checks to see if file is a recognized archive.
- If so, unpacks it into work area.
- If not, copies it into work area as is.
- NOTE: .dms files are not unpacked, but are tested for integrity
- */
-
- response=0
-
- /*
- if index(fpath,'/')>0 then /* allow for missing or invalid path */
- fname=reverse(delstr(reverse(fpath),pos('/',reverse(fpath))))
- else fname=fpath
- */
-
- if index(fpath,'/')=0 & index(fpath,':')=0 then do
- fname=fpath
- fpath=Home_Dir||'/'||fname
- end
-
- If ~Open('file',fpath,'R') then Do
- say 'Can''t open '||fpath
- return 99
- end
-
- fsig = readch('file',12) /* read filetype signature */
- call close('file')
- if length(fsig) < 12 then do
- say||fname' is too short to be genuine.'
- return 99
- end
-
- gnome=Pragma('D',WorkDir) /* set current dir to WorkArea */
- select
- when substr(fsig,3,3)='-lh' then Address Command 'LhA >NIL: -mMqa -P2 -x0 e '||fpath
- when left(fsig,3) = 'LZX' then Address Command 'LZX >NIL: -m x '||fpath
- when left(fsig,1) = "1a"x then Address Command 'Pkax >NIL: -e '||fpath
- when left(fsig,2) = "60ea"x then address command 'unarj >NIL: e '||fpath
- when left(fsig,3) = 'ZOO' then Address Command 'Zoo >NIL: e// '||fpath
- when left(fsig,2) = 'PK' then Address Command 'unzip >NIL: '||fpath
- when left(fsig,3) = "DMS" then do
- say 'Can''t unpack a DMS file'
- gnome=Pragma('D',Home_Dir) /* restore current dir */
- address command 'dms >NIL: test '||fpath
- say 'DMS integrity test returns error code '||RC
- response=10
- return response
- end
- otherwise do
- gnome=Pragma('D',Home_Dir) /* restore current dir */
- address command 'copy 'fpath' to 'WorkDir
- return 0
- end
- end
- response=RC /* return code from unpackers */
- if response ~=0 then say 'Unpacker returns error code '||response
- gnome=Pragma('D',Home_Dir) /* restore current dir */
- return response
-
- Viruscheck:
- address 'Virus_CheckerII' 'SCAN '||WorkDir
- vircount = VCHECK.0.0
- if vircount = 'VCHECK.0.0' then vircount = +0 /* force numeric */
- say ' '||vircount 'virus(es) found.'
- if vircount ~=0 then do
- do i=1 to vircount /* was "to VCHECK.0.0" */
- say ' File: '||VCHECK.i.1||' Virus: '||VCHECK.i.2
- end
- say
- end
- return vircount
-
- Load_VC:
- response=0
- if ~show(Ports,'Virus_CheckerII') then do
- if exists(VCdir||'Virus_CheckerII') then do
- address command 'run <>nil: '||VCdir||'Virus_CheckerII N XFD'
- do i=1 to 3
- address command 'waitforport Virus_CheckerII'
- if RC=0 then break
- end
- end
- if ~show(Ports,'Virus_CheckerII') then response=10
- end
- return response
-
-
- /*------------------------------------------------------------*/
- SYNTAX:
- FAILURE:
- Error = rc
- Myline = SIGL
- gnome=Pragma('D',Home_Dir)
- say 'Error: '||Error||' Line '||myline||'. '||ErrorText(Error)
- Exit 30
-
-